package com.project.dao.impl;

import java.sql.SQLException;
import java.util.List;

import com.project.dao.IUserLoginDao;
import com.project.dao.bean.Customer;

/**
 * 登录Dao Implement
 * @author Sn
 *
 */
public class UserLoginDaoImpl extends BaseDaoImpl implements IUserLoginDao
{
	public int login(Customer customer) 
	{
		//返回用户信息list
		List<Customer> customerlist = null;
		//返回值
		int rtnInt = 0;
		
		try 
		{
			customerlist=this.getSqlMapClient().queryForList("Customerlogin", customer.getCust_id());
			 
			if (customerlist.size() > 1)
			{
				//异常错误，登录名不唯一
				rtnInt = 4;
				
			}else if (customerlist.size() < 1)
			{
				//用户名不存在
				rtnInt = 3;
				
			}else if (customerlist.get(0).getCust_pwd().equals(customer.getCust_pwd())) 
			{
				//登录成功
				rtnInt = 1;
				
			}else
			{
				//密码错误
				rtnInt = 2;
			}	
			 
		} catch (SQLException e) 
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		return rtnInt;
	}
}
